using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

namespace KeyCore.Domain.Model
{
    public class User
    {
        [Key,DatabaseGenerated(DatabaseGeneratedOption.Identity)]
        public Guid  UserId { get; set; }

        public int RoleId { get; set; }

        [ForeignKey("RoleId")]
        public virtual UserRoles UserRole { get; set; }

        [Required]
        [StringLength(50)]
        public string UserName { get; set; }

        [Required]
        [StringLength(100)]
      /* walidacja emaila wymaga poprawy
       * w crteate user uzylem isValidEmail
       * [RegularExpression(@"^(?!\.)(""([^""\r\\]|\\[""\r\\])*""|"
       *         + @"([-a-z0-9!#$%&'*+/=?^_`{|}~]|(?<!\.)\.)*)(?<!\.)"
       *         + @"@[a-z0-9][\w\.-]*[a-z0-9]\.[a-z][a-z\.]*[a-z]$")]
       */
        public string Email { get; set; }

        [Required]
        [StringLength(250)]
        public string Password { get; set; }

        [Required(AllowEmptyStrings = true)]
        [StringLength(250)]
        public string PasswordSalt { get; set; }

        [Required]
        [DisplayFormat(DataFormatString = "{0:dd/MM/yyyy}")]
        public System.DateTime CreatedDate { get; set; }

        [DisplayFormat(DataFormatString = "{0:dd/MM/yyyy}")]
        public System.DateTime? LastModifiedDate { get; set; }

        [DisplayFormat(DataFormatString = "{0:dd/MM/yyyy}")]
        public System.DateTime? LastLoginDate { get; set; }

        [Required]
        public bool IsApproved { get; set; }

        public bool IsLocked { get; set; }

        [StringLength(250)]
        public string AccountActivationCode { get; set; }

        [StringLength(250)]
        public string PasswordResetCode { get; set; }
    }
}
